package cn.zf233.xcloud.commom.enums;

/**
 * Created by zf233 on 2020/1/30
 * 可排序字段
 */
public enum SortFieldENUM {

    SORT_FILED_ENUM("old_file_name", 0),
    FILE_TYPE("file_type", 1),
    FILE_SIZE("file_size", 2),
    UPLOAD_TIME("upload_time", 3);

    private String describe;
    private Integer code;

    public static SortFieldENUM fieldOf(int code) {
        for (SortFieldENUM sortFieldENUM : values()) {
            if (sortFieldENUM.getCode() == code) {
                return sortFieldENUM;
            }
        }
        throw new RuntimeException("未知");
    }

    public static boolean exists(int code) {
        for (SortFieldENUM sortFieldENUM : values()) {
            if (sortFieldENUM.getCode() == code) {
                return true;
            }
        }
        return false;
    }

    SortFieldENUM(String describe, Integer code) {
        this.describe = describe;
        this.code = code;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getDescribe() {
        return describe;
    }

    public void setDescribe(String describe) {
        this.describe = describe;
    }
}